home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / allfiles / Itch / work_info / WImage.dcr / 00021_TV Parent.ls < prev    next >
Encoding:
Text File  |  1999-03-07  |  2.3 KB  |  115 lines

  1. property sp, cst, pos, state, hitCounter, TVPicList, TVtimer, flickerTimer, lightTimer, greetCherubObj
  2.  
  3. on new me, asp
  4.   me.sp = asp
  5.   puppetSprite(me.sp, 1)
  6.   sprite(me.sp).visible = 1
  7.   me.cst = the member of sprite me.sp
  8.   me.pos = the loc of sprite me.sp
  9.   me.state = #noise
  10.   TVPicList = []
  11.   makeList(me, TVPicList, "TV")
  12.   me.hitCounter = 0
  13.   return me
  14. end
  15.  
  16. on CheckState me
  17.   case me.state of
  18.     #noise:
  19.       FlickPics(me, TVPicList)
  20.     #thumped:
  21.       CountHits(me)
  22.     #Flicker:
  23.       Flicker(me)
  24.     #working:
  25.       me.state = #greeting
  26.       SwapCast(me, member("TreeLights"))
  27.       greetCherubObj = new(script("GreetingCherub Parent"), me.sp + 2)
  28.     #greeting:
  29.       FlashLights(me)
  30.       CheckState(greetCherubObj)
  31.   end case
  32. end
  33.  
  34. on FlickPics me, aList
  35.   if the timer > TVtimer then
  36.     tempPos = getOne(aList, me.cst)
  37.     tempCast = random(count(aList))
  38.     if tempCast = tempPos then
  39.       FlickPics(me, TVPicList)
  40.     else
  41.       CueTVTimer(me, 3)
  42.       SwapCast(me, getAt(aList, tempCast))
  43.     end if
  44.   end if
  45. end
  46.  
  47. on FlashLights me
  48.   if the timer > lightTimer then
  49.     CueLightTimer(me, 10)
  50.     if sprite(me.sp).visible = 0 then
  51.       sprite(me.sp).visible = 1
  52.     else
  53.       sprite(me.sp).visible = 0
  54.     end if
  55.   end if
  56. end
  57.  
  58. on CueLightTimer me, aNum
  59.   lightTimer = the timer + aNum
  60. end
  61.  
  62. on CueTVTimer me, aNum
  63.   TVtimer = the timer + aNum
  64. end
  65.  
  66. on CountHits me
  67.   me.hitCounter = me.hitCounter + 1
  68.   CueflickerTimer(me, 60)
  69.   me.state = #Flicker
  70. end
  71.  
  72. on Flicker me
  73.   if the timer > flickerTimer then
  74.     case hitCounter of
  75.       3:
  76.         sprite(me.sp).visible = 0
  77.         me.state = #working
  78.       otherwise:
  79.         sprite(me.sp).visible = 1
  80.         me.state = #noise
  81.     end case
  82.   else
  83.     temp = random(5)
  84.     case temp of
  85.       1:
  86.         sprite(me.sp).visible = 0
  87.       otherwise:
  88.         sprite(me.sp).visible = 1
  89.     end case
  90.   end if
  91. end
  92.  
  93. on CueflickerTimer me, aNum
  94.   flickerTimer = the timer + aNum
  95. end
  96.  
  97. on makeList me, aList, aName
  98.   repeat with x = 1 to the maxinteger
  99.     if the number of member (aName & x) > 0 then
  100.       add(aList, member(aName & x))
  101.       next repeat
  102.     end if
  103.     exit repeat
  104.   end repeat
  105. end
  106.  
  107. on SwapCast me, aMem
  108.   me.cst = aMem
  109.   set the member of sprite the sp of me to me.cst
  110. end
  111.  
  112. on DrawtoStage me
  113.   set the loc of sprite the sp of me to me.pos
  114. end
  115.